package com.toogu.mazhangmen.ui.monitor;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.toogu.mazhangmen.R;
import com.toogu.mazhangmen.bean.EquipmentsBean;
import com.toogu.mazhangmen.util.MonitorUtil;

public class ControlFragment extends Fragment {
    private EquipmentsBean equipmentsBean;
    private ControlPresenter presenter;
    private MonitorUtil monitorUtil;
    public ControlFragment(EquipmentsBean equipmentsBean, MonitorUtil monitorUtil){
        this.equipmentsBean=equipmentsBean;
        this.monitorUtil=monitorUtil;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_scroll, container, false);
        ControlContract.IView view = new ControlView(getActivity(),rootView,equipmentsBean);
        ControlContract.IModel model = new ControlModel(getActivity());
        presenter = new ControlPresenter(getActivity(),equipmentsBean,monitorUtil);
        presenter.onCreate(view,model);
        return rootView;
    }

    @Override
    public void onStart() {
        super.onStart();
        presenter.onResume();
    }

    @Override
    public void onStop() {
        super.onStop();
        presenter.onPause();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        presenter.onDestory();
    }

}
